Imports DAL
Imports MyClasses
Imports System.Collections
Imports System.Configuration

Public Class frmVendor1
    Dim _intVendorID As Integer
    Dim blnCountryFlag As Boolean
    Dim blnStateFlag As Boolean
    Dim blnCityFlag As Boolean
    Dim address(0) As CAddress
    'Dim btFlag As Byte
    Dim HstItemList As New Hashtable
    Dim updtAddress(0) As CAddress
    Dim Flag As Byte

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()        
    End Sub

    Private Function isUpdate() As Boolean
        Try
            If checkTag() Then
                Return True
            Else
                Return isEqual()
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "isUpdate")
            Me.Cursor = Cursors.Default
        End Try
    End Function

    Private Sub setTag()
        Try
            cmbVendorCat.Tag = cmbVendorCat.SelectedValue
            txtVendorName.Tag = txtVendorName.Text
            txtRegisteredName.Tag = txtRegisteredName.Text
            cmbTitle.Tag = cmbTitle.SelectedValue
            txtFname.Tag = txtFname.Text
            txtMname.Tag = txtMname.Text
            txtLname.Tag = txtLname.Text
            txtFDA.Tag = txtFDA.Text
            txtLST.Tag = txtLST.Text
            txtCST.Tag = txtCST.Text
            txtPAN.Tag = txtPAN.Text
            cmbPayMode.Tag = cmbPayMode.SelectedValue
            txtDeliveryPeriod.Tag = txtDeliveryPeriod.Text
            txtCreditTime.Tag = txtCreditTime.Text
            txtNotes.Tag = txtNotes.Text
            txtAddr1.Tag = txtAddr1.Text
            txtPinCode.Tag = txtPinCode.Text
            cmbCountry.Tag = cmbCountry.SelectedValue
            cmbState.Tag = cmbState.SelectedValue
            cmbcity.Tag = cmbcity.SelectedValue
            txtPhone1.Tag = txtPhone1.Text
            txtPhone2.Tag = txtPhone2.Text
            txtMobile1.Tag = txtMobile1.Text
            txtMobile2.Tag = txtMobile2.Text
            txtFax.Tag = txtFax.Text
            txtEmail.Tag = txtEmail.Text
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "setTag")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub clearTag()
        Try
            cmbVendorCat.Tag = ""
            txtVendorName.Tag = ""
            txtRegisteredName.Tag = ""
            cmbTitle.Tag = ""
            txtFname.Tag = ""
            txtMname.Tag = ""
            txtLname.Tag = ""
            txtFDA.Tag = ""
            txtLST.Tag = ""
            txtCST.Tag = ""
            txtPAN.Tag = ""
            cmbPayMode.Tag = ""
            txtDeliveryPeriod.Tag = ""
            txtCreditTime.Tag = ""
            txtNotes.Tag = ""
            txtAddr1.Tag = ""
            txtPinCode.Tag = ""
            cmbCountry.Tag = ""
            cmbState.Tag = ""
            cmbcity.Tag = ""
            txtPhone1.Tag = ""
            txtPhone2.Tag = ""
            txtMobile1.Tag = ""
            txtMobile2.Tag = ""
            txtFax.Tag = ""
            txtEmail.Tag = ""
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "setTag")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    'Checks for Updation on the address ingformation
    Private Function isEqual() As Boolean
        Dim intc As New Integer
        Try
            For intc = 0 To address.Length - 1
                If IsNothing(address(intc)) Then Continue For
                If IsNothing(updtAddress(intc)) Then Return False : Me.Cursor = Cursors.Default : Exit Function
                With address(intc)
                    If updtAddress(intc).City <> .City Or updtAddress(intc).Country <> .Country Or _
                    updtAddress(intc).Description1 <> .Description1 Or updtAddress(intc).Description2 <> .Description2 Or _
                    updtAddress(intc).State <> .State Or updtAddress(intc).PhoneNo1 <> .PhoneNo1 Or _
                    updtAddress(intc).PhoneNo2 <> .PhoneNo2 Or updtAddress(intc).PinCode <> .PinCode Or _
                    updtAddress(intc).EmailID <> .EmailID Or updtAddress(intc).WebSiteAddress <> .WebSiteAddress Then
                        Me.Cursor = Cursors.Default
                        Return True
                        Exit Function
                    End If
                End With
            Next
            Return False
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "isEqual")
            Me.Cursor = Cursors.Default
            Return False
        End Try
    End Function

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            If ValidateData() Then
                If SaveData() Then
                    If btnSave.Text = "&Save" Then
                        BCommon.ShowMsgError(3)
                    Else
                        BCommon.ShowMsgError(5)
                    End If
                    Call ClearData()
                    Call Display_Data()
                    txtVendorName.Focus()
                Else
                    BCommon.ShowMsgError(4)
                End If
            Else
                Me.Cursor = Cursors.Default
            End If
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnSave_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Function SaveData() As Boolean
        Try
            Dim Result As Boolean
            If btnSave.Text = "&Save" Then
                Result = BVendor.Save(SetData, "S", SetAddress(), HstItemList)
            Else
                Result = BVendor.Save(SetData, "U", SetAddress(), HstItemList)
            End If
            Return Result
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "SaveData")
            Me.Cursor = Cursors.Default
        End Try
    End Function

    Private Function SetData() As CVendor
        Dim objVendor As New CVendor
        Try
            With objVendor
                .VendorID = _intVendorID
                .SeqVendorID = txtvendorID.Text
                .VendorName = txtVendorName.Text
                .VendorCat = cmbVendorCat.SelectedValue
                .RegisteredName = txtRegisteredName.Text
                .FDANUM = Trim(txtFDA.Text)
                .LSTNUM = Trim(txtLST.Text)
                .CSTNUM = Trim(txtCST.Text)
                .PANNUM = Trim(txtPAN.Text)
                .PayMode = cmbPayMode.SelectedValue
                .DeliveryTime = IIf(txtDeliveryPeriod.Text = "", 0, txtDeliveryPeriod.Text)
                .CreditPeriod = IIf(Trim(txtCreditTime.Text) = "", 0, Trim(txtCreditTime.Text))
                .Remark = Trim(txtNotes.Text)
            End With
            With objVendor.PersonID
                .Title = cmbTitle.SelectedValue
                .First_Name = IIf(Trim(txtFname.Text) <> "<First Name>" Or Trim(txtFname.Text) <> "", Trim(txtFname.Text), "")
                .Middle_Name = IIf(Trim(txtMname.Text) <> "<Middle Name>" Or Trim(txtMname.Text) <> "", Trim(txtMname.Text), "")
                .Last_Name = IIf(Trim(txtLname.Text) <> "<Last Name>" Or Trim(txtLname.Text) <> "", Trim(txtLname.Text), "")
            End With
            Return objVendor
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "SetData")
            Me.Cursor = Cursors.Default
            Return Nothing
        End Try
    End Function

    Private Function SetAddress() As CAddress()
        address(0) = New CAddress
        Try
            With address(0)
                If btnSave.Text = "&Update" Then
                    .AddressID = BVendor.SetAddressID(_intVendorID)
                End If
                .AddressType = "CO"
                .Description1 = Trim(txtAddr1.Text)
                .Country = cmbCountry.SelectedValue
                .State = cmbState.SelectedValue
                .PinCode = IIf(Trim(txtPinCode.Text) <> "", Trim(txtPinCode.Text), 0)
                If cmbcity.SelectedValue = Nothing Then
                    If cmbcity.Text <> "" Then
                        .City = DAddress.SaveCity(.State, .Country, cmbcity.Text, .PinCode)
                    End If
                Else
                    .City = cmbcity.SelectedValue
                End If
                .PhoneNo1 = Trim(txtPhone1.Text)
                .PhoneNo2 = Trim(txtPhone2.Text)
                .MobileNo1 = Trim(txtMobile1.Text)
                .MobileNo2 = Trim(txtMobile2.Text)
                .Fax = Trim(txtFax.Text)
                .EmailID = Trim(txtEmail.Text)
            End With
            Return address

        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "SetAddress")
            Me.Cursor = Cursors.Default
            Return Nothing
        End Try
    End Function

    ' Displays the State name according to the Country Name Selected
    Private Sub GetCountryState()
        Dim dtcountry As New DataTable
        Try

            dtcountry = DAddress.GetCountryStates(cmbCountry.SelectedValue)
            blnStateFlag = False
            BCommon.SetComboValues(cmbState, dtcountry, "StateCD", "Description")
            blnStateFlag = True
            If ConfigurationManager.AppSettings("Country") = cmbCountry.SelectedValue Then
                cmbState.SelectedValue = ConfigurationManager.AppSettings("State")
                cmbState.Refresh()
            Else
                cmbcity.Text = ""
                txtPinCode.Text = ""
                cmbState.Text = ""
            End If
            GetStateCity(cmbState.SelectedValue)

        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "GetCountryState")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    'Displays the city name according to the state selected
    Private Sub GetStateCity(ByVal intaddrS As Integer)

        Dim dtstate As New DataTable
        Try
            dtstate = DAddress.GetStateCity(intaddrS, cmbCountry.SelectedValue)
            blnCityFlag = False
            BCommon.SetComboValues(cmbcity, dtstate, "CityCD", "Description")
            blnCityFlag = True
            If cmbcity.Items.Count > 0 Then
                If ConfigurationManager.AppSettings("Country") = cmbCountry.SelectedValue And ConfigurationManager.AppSettings("State") = cmbState.SelectedValue Then cmbcity.SelectedValue = ConfigurationManager.AppSettings("City")
            Else
                cmbcity.Text = ""
                txtPinCode.Text = ""
            End If
            cmbcity.Refresh()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "GetStateCity")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    '   Displays the pincode of the corresponding city
    Private Sub GetCityPincode(ByVal intaddrci As Integer)
        Dim intpincode As Integer
        Try
            intpincode = DAddress.GetCityPinCode(intaddrci)
            txtPinCode.Text = intpincode
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "GetCityPincode")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbCountry_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbCountry.SelectedIndexChanged
        If blnCountryFlag = False Then Me.Cursor = Cursors.Default : Exit Sub
        Call GetCountryState()
    End Sub

    Private Sub cmbState_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbState.SelectedIndexChanged
        If blnStateFlag = False Then Me.Cursor = Cursors.Default : Exit Sub
        Call GetStateCity(cmbState.SelectedValue)
    End Sub

    Private Sub cmbCity_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbcity.SelectedIndexChanged
        If blnCityFlag = False Then Me.Cursor = Cursors.Default : Exit Sub
        If cmbcity.Items.Count > 0 Then
            Call GetCityPincode(cmbcity.SelectedValue)
        End If
    End Sub
    Private Sub cmbCountry_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbCountry.GotFocus
        If cmbCountry.SelectedValue = Nothing Then
            cmbCountry.SelectedValue = ConfigurationManager.AppSettings("Country")
        End If
    End Sub

    Private Sub cmbcountry_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbCountry.KeyDown
        'Rahul_ITS@2007113 : Add following line
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then cmbState.Focus()
    End Sub

    Private Sub view_Addr(ByVal intPersonID As Integer)

        Dim dtbAddr As New DataTable
        Dim intc As Integer = 0
        Try
            dtbAddr = DAddress.SearchAddress(intPersonID)
            'For Each row As DataRow In dtbAddr.Rows
            If IsNothing(dtbAddr.Rows(intc)) Then Me.Cursor = Cursors.Default : Exit Sub

            With dtbAddr.Rows(intc)
                txtAddr1.Text = .Item(1)
                txtAddr1.Tag = txtAddr1.Text

                txtPinCode.Text = IIf(.Item(3) = "0", "", .Item(3))
                txtPinCode.Tag = txtPinCode.Text

                cmbCountry.SelectedValue = .Item(6)
                cmbCountry.Tag = cmbCountry.SelectedValue

                cmbState.SelectedValue = .Item(5)
                cmbState.Tag = cmbState.SelectedValue

                cmbcity.SelectedValue = .Item(4)
                cmbcity.Tag = cmbcity.SelectedValue

                txtPhone1.Text = .Item(7)
                txtPhone1.Tag = txtPhone1.Text

                txtPhone2.Text = .Item(8)
                txtPhone2.Tag = txtPhone2.Text

                txtMobile1.Text = .Item(9)
                txtMobile1.Tag = txtMobile1.Text

                txtMobile2.Text = .Item(10)
                txtMobile2.Tag = txtMobile2.Text

                txtFax.Text = IIf(.Item(11) = "0", "", .Item(11))
                txtFax.Tag = txtFax.Text

                txtEmail.Text = .Item(12)
                txtEmail.Tag = txtEmail.Text

            End With
            'Next
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "view_Addr")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Function checkTag() As Boolean
        Try
            If Trim(txtVendorName.Text) <> Trim(txtVendorName.Tag) Or cmbVendorCat.SelectedValue <> cmbVendorCat.Tag _
            Or Trim(txtAddr1.Text) <> txtAddr1.Tag Or Trim(txtAddr1.Text) <> txtAddr1.Tag _
            Or cmbCountry.SelectedValue <> cmbCountry.Tag Or cmbState.SelectedValue <> cmbState.Tag Or cmbcity.SelectedValue <> cmbcity.Tag _
            Or Trim(txtPinCode.Text) <> txtPinCode.Tag Or Trim(txtPhone1.Text) <> txtPhone1.Tag Or Trim(txtPhone2.Text) <> txtPhone2.Tag _
            Or Trim(txtMobile1.Text) <> txtMobile1.Tag Or Trim(txtMobile2.Text) <> txtMobile2.Tag Or Trim(txtFax.Text) <> txtFax.Tag _
            Or Trim(txtEmail.Text) <> txtEmail.Tag Or Trim(txtLST.Text) <> txtLST.Tag Or Trim(txtCST.Text) <> txtCST.Tag _
            Or Trim(txtRegisteredName.Text) <> txtRegisteredName.Tag Or Trim(txtFDA.Text) <> txtFDA.Tag _
            Or Trim(txtPAN.Text) <> txtPAN.Tag Or cmbPayMode.SelectedValue <> cmbPayMode.Tag Or Trim(txtDeliveryPeriod.Text) <> txtDeliveryPeriod.Tag _
            Or Trim(txtCreditTime.Text) <> txtCreditTime.Tag Or Trim(txtNotes.Text) <> txtNotes.Tag Or cmbTitle.SelectedValue <> cmbTitle.Tag _
            Or Trim(txtFname.Text) <> txtFname.Tag Or Trim(txtMname.Text) <> txtMname.Tag Or Trim(txtLname.Text) <> txtLname.Tag Or Flag = 1 Then
                'Or HstItemList.Values.Count <> intlistItems Then
                Return True
            Else : Return False
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "checkTag")
            Me.Cursor = Cursors.Default
        End Try
    End Function
    'Code End
    Private Sub ClearData()
        Try
            btnSave.Text = "&Save"
            btnDelete.Enabled = False
            txtVendorName.Text = ""
            cmbVendorCat.SelectedValue = 0
            txtAddr1.Text = ""
            cmbcity.SelectedValue = 0
            cmbState.SelectedValue = 0
            cmbCountry.SelectedValue = 0
            cmbmanufacturer.SelectedIndex = -1
            lstitemvndr.DataSource = Nothing
            txtPhone1.Text = ""
            txtPhone2.Text = ""
            txtMobile1.Text = ""
            txtMobile2.Text = ""
            txtFax.Text = ""
            txtEmail.Text = ""
            txtRegisteredName.Text = ""
            'Rahul_ITS@20072412
            '<<START
            txtFname.Tag = "<First Name>"
            txtMname.Tag = "<Middle Name>"
            txtLname.Tag = "<Last Name>"
            txtFname.Text = txtFname.Tag
            txtMname.Text = txtMname.Tag
            txtLname.Text = txtLname.Tag
            cmbTitle.SelectedValue = Replace(ConfigurationManager.AppSettings("Title"), ".", "")
            cmbTitle.Tag = cmbTitle.SelectedValue
            If ConfigurationManager.AppSettings("NameSeq") = "TLFM" Then
                txtLname.Location = New Point(203, 60)
                txtFname.Location = New Point(303, 60)
                txtMname.Location = New Point(402, 60)
            End If
            '>>END
            txtFDA.Text = ""
            txtLST.Text = ""
            txtCST.Text = ""
            txtPAN.Text = ""
            cmbPayMode.SelectedValue = Replace(ConfigurationManager.AppSettings("Title"), ".", "")
            txtDeliveryPeriod.Text = ""
            txtCreditTime.Text = ""
            txtNotes.Text = ""
            txtvendorID.Text = BCommon.GetSequentialID("VENDOR")
            address(0) = Nothing
            HstItemList.Clear()
            Call clearTag()
            Call setTag()
            '****
            'txtFname.Text = "<First Name>"
            'txtMname.Text = "<Middle Name>"
            'txtLname.Text = "<Last Name>"
            '***
            ' cmbTitle.SelectedValue = cmbTitle.Tag
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "ClearData")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            Call ClearData()
            Call Display_Data()
            Call setTag()
            blnCountryFlag = True
            blnStateFlag = True
            blnCityFlag = True
            txtVendorName.Focus()
            cmbTitle.Tag = cmbTitle.SelectedValue
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnCancel_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub Display_Data()
        Dim dtbmanufacturer As DataTable
        Try
            Call BCommon.SetFormStandards(Me)
            dtbmanufacturer = BManufacturer.GetManufacturers()
            BCommon.SetComboValues(cmbmanufacturer, dtbmanufacturer, "mfctrID", "mfctrName")

            BCommon.SetComboValues(cmbVendorCat, "VENDORCAT", True)
            BCommon.SetComboValues(cmbPayMode, "PAYMODE", False)
            BCommon.SetComboValues(cmbTitle, "TITLE", False)

            BCommon.SetComboValues(cmbcity, DAddress.GetCity, "CityCD", "Description")
            BCommon.SetComboValues(cmbState, DAddress.GetState, "StateCD", "Description")
            BCommon.SetComboValues(cmbCountry, DAddress.GetCountry, "CountryCD", "Description")

            btnSave.Text = "&Save"
            btnDelete.Enabled = False
            If dtbmanufacturer.Rows.Count <> 0 Then
                Call selectVendorManufacturer(cmbmanufacturer.SelectedValue.ToString, lstitemmfr)
            End If

            cmbTitle.Tag = cmbTitle.SelectedValue

            txtFname.Text = txtFname.Tag
            txtMname.Text = txtMname.Tag
            txtLname.Text = txtLname.Tag
            txtvendorID.Text = BCommon.GetSequentialID("VENDOR")
            cmbCountry.SelectedIndex = -1
            cmbState.SelectedIndex = -1
            cmbcity.SelectedIndex = -1
            cmbmanufacturer.SelectedIndex = -1

            cmbTitle.SelectedValue = Replace(BCommon.GetConfigValues("Title"), ".", "")

            'Divya 12/21/2007
            If ConfigurationManager.AppSettings("NameSeq") = "TLFM" Then
                txtLname.Location = New Point(203, 60)
                txtFname.Location = New Point(303, 60)
                txtMname.Location = New Point(402, 60)
            End If
            '>>End
            Call setTag()  'Modified By:-VINIT(2008/01/18)
            BCommon.SetTextReadOnly(txtvendorID) 'Divya 31/01/2008 : Added for ReadOnly fields
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "DisplayData")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub ViewData()
        Dim dtsVendor As New DataSet
        Dim dtDItems As New DataTable
        'Dim dtManufacturer As DataTable
        Dim dtManufacturer As New DataSet
        Dim Person As New CPerson
        Dim strItem As New System.Text.StringBuilder
        'Dim sb As New System.Text.StringBuilder
        Dim intMCode As Integer = 0, intCount As Integer
        'sb.
        Try

            dtsVendor = BVendor.GetVendor(_intVendorID)
            dtDItems = DItem.GetvendorItem(_intVendorID)
            If dtDItems.Rows.Count > 0 Then
                For intCount = 0 To dtDItems.Rows.Count - 1
                    If intMCode = 0 Then
                        intMCode = dtDItems.Rows(intCount).Item(1)
                    End If
                    If intMCode <> dtDItems.Rows(intCount).Item(1) Then
                        HstItemList.Add(intMCode, strItem.ToString)
                        intMCode = dtDItems.Rows(intCount).Item(1)
                        strItem = strItem.Remove(0, strItem.Length)
                        strItem = strItem.Append(dtDItems.Rows(intCount).Item(3))
                    Else
                        If strItem.Length = 0 Then
                            strItem = strItem.Append(dtDItems.Rows(intCount).Item(3))
                        Else
                            strItem = strItem.Append("," + dtDItems.Rows(intCount).Item(3))
                        End If
                    End If
                Next
                HstItemList.Add(intMCode, strItem.ToString)
            End If

            'Rahul_ITS@20072012 : Add to select Manufacturer ID for Vendor
            dtManufacturer = BVendor.GetManufacturerItem(_intVendorID)
            If dtManufacturer.Tables(0).Rows.Count > 0 Then
                With dtManufacturer.Tables(0).Rows(0)
                    cmbmanufacturer.SelectedValue = .Item(0)
                End With
            End If

            With dtsVendor.Tables(0).Rows(0)
                txtvendorID.Text = .Item(1)
                Person = BPerson.GetPerson(.Item(2))
                cmbVendorCat.SelectedValue = .Item(3)
                cmbVendorCat.Tag = cmbVendorCat.SelectedValue

                txtVendorName.Text = .Item(4)
                txtVendorName.Tag = txtVendorName.Text

                txtRegisteredName.Text = .Item(5)
                txtRegisteredName.Tag = txtRegisteredName.Text

                cmbTitle.SelectedValue = Person.Title
                cmbTitle.Tag = cmbTitle.SelectedValue

                txtFname.Text = IIf(Person.First_Name = "<First Name>", "", Person.First_Name)
                txtFname.Tag = txtFname.Text

                txtMname.Text = IIf(Person.Middle_Name = "<Middle Name>", "", Person.Middle_Name)
                txtMname.Tag = txtMname.Text

                txtLname.Text = IIf(Person.Last_Name = "<Last Name>", "", Person.Last_Name)
                txtLname.Tag = txtLname.Text

                txtFDA.Text = .Item(6)
                txtFDA.Tag = txtFDA.Text

                txtLST.Text = .Item(7)
                txtLST.Tag = txtLST.Text

                txtCST.Text = .Item(8)
                txtCST.Tag = txtCST.Text

                txtPAN.Text = .Item(9)
                txtPAN.Tag = txtPAN.Text

                cmbPayMode.SelectedValue = .Item(12)
                cmbPayMode.Tag = cmbPayMode.SelectedValue

                txtDeliveryPeriod.Text = IIf(.Item(14) = "0", "", .Item(14))
                txtDeliveryPeriod.Tag = txtDeliveryPeriod.Text

                txtCreditTime.Text = IIf(.Item(15) = "0", "", .Item(15))
                txtCreditTime.Tag = txtCreditTime.Text

                txtNotes.Text = .Item(17)
                txtNotes.Tag = txtNotes.Text

                Call view_Addr(.Item(2))
            End With
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "ViewData")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub frmVendor1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Try
            If Not (ConfigurationManager.AppSettings("FormMode") = "R") Then
                Me.Cursor = Cursors.WaitCursor
                If isUpdate() Then
                    Select Case BCommon.ShowMsgError(10081, "YNC")
                        Case Windows.Forms.DialogResult.Yes
                            If ValidateData() Then
                                If SaveData() Then
                                    If btnSave.Text = "&Save" Then
                                        BCommon.ShowMsgError(3)
                                    Else
                                        BCommon.ShowMsgError(5)
                                    End If
                                Else
                                    BCommon.ShowMsgError(4)
                                End If
                            End If
                        Case Windows.Forms.DialogResult.Cancel
                            e.Cancel = True
                        Case Windows.Forms.DialogResult.No
                    End Select
                End If
                Me.Cursor = Cursors.Default
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnClose_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub frmVendor1_HelpButtonClicked(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Me.HelpButtonClicked
        'Rauhl_ITS@20073012 : Add following code display help        
        Help.ShowHelp(Me, "Pharma.chm", HelpNavigator.KeywordIndex, "Vendor")
        e.Cancel = True
    End Sub

    Private Sub frmVendor1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
        If e.KeyCode = Keys.F1 Then
            'Rauhl_ITS@20073012 : Add following code display help            
            e.SuppressKeyPress = True
            Help.ShowHelp(Me, "Pharma.chm", HelpNavigator.KeywordIndex, "Vendor")
        End If
    End Sub

    Private Sub frmVendor_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Call Display_Data()
        blnCountryFlag = True
        blnStateFlag = True
        blnCityFlag = True
        cmbTitle.Tag = cmbTitle.SelectedValue
    End Sub

    Private Sub txtfname_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtFname.GotFocus
        If txtFname.Text = txtFname.Tag Then
            txtFname.Text = ""
        End If
    End Sub

    Private Sub txtmname_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMname.GotFocus
        If txtMname.Text = txtMname.Tag Then
            txtMname.Text = ""
        End If
    End Sub

    Private Sub txtlname_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtLname.GotFocus
        If txtLname.Text = txtLname.Tag Then
            txtLname.Text = ""
        End If
    End Sub

    Private Sub txtLname_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtLname.KeyDown
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then
            If ConfigurationManager.AppSettings("NameSeq") = "TLFM" Then
                txtFname.Focus()
            Else
                txtFDA.Focus()
            End If
        Else
            If e.Shift = True Then
                If e.KeyCode = Keys.OemQuotes Then
                    e.SuppressKeyPress = True
                End If
                If BCommon.ValidateText(e.KeyCode, "ALF", False) = False Then
                    e.SuppressKeyPress = True
                End If
            End If
        End If
    End Sub

    'Divya@13/02/2008 : Added for Tab key sequence for Name
    Private Sub txtLname_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtLname.Leave
        If Keys.Tab Then
            If ConfigurationManager.AppSettings("NameSeq") = "TLFM" Then
                txtFname.Focus()
            Else
                txtFDA.Focus()
            End If
        End If
    End Sub

    Private Sub txtFname_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtFname.KeyDown
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then
            txtMname.Focus()
        Else
            If e.Shift = True Then
                If e.KeyCode = Keys.OemQuotes Then
                    e.SuppressKeyPress = True
                End If
                If BCommon.ValidateText(e.KeyCode, "ALF", False) = False Then
                    e.SuppressKeyPress = True
                End If
            End If
        End If
    End Sub

    Private Sub txtMname_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtMname.KeyDown
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then
            If ConfigurationManager.AppSettings("NameSeq") = "TLFM" Then
                txtFDA.Focus()
            Else
                txtLname.Focus()
            End If
        Else
            If e.Shift = True Then
                If e.KeyCode = Keys.OemQuotes Or e.KeyCode = Keys.OemPeriod Then
                    e.SuppressKeyPress = True
                End If
                If BCommon.ValidateText(e.KeyCode, "ALF", False) = False Then
                    e.SuppressKeyPress = True
                End If
            End If
        End If
    End Sub

    Private Sub txtMname_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMname.Leave
        'Divya@13/02/2008 : Added for Tab key sequence for Name
        If Keys.Tab Then
            If ConfigurationManager.AppSettings("NameSeq") = "TLFM" Then
                txtFDA.Focus()
            Else
                txtLname.Focus()
            End If
        End If
    End Sub

    Private Sub txtFname_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtFname.LostFocus
        txtFname.Text = IIf(Trim(txtFname.Text) = "", txtFname.Tag, Trim(txtFname.Text))
        If txtFname.Text <> "" Or txtFname.Text <> txtFname.Tag Then
            txtFname.Text = UCase(Mid(txtFname.Text, 1, 1)) & Mid(txtFname.Text, 2)
        End If
    End Sub

    Private Sub txtMname_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMname.LostFocus
        txtMname.Text = IIf(Trim(txtMname.Text) = "", txtMname.Tag, Trim(txtMname.Text))
        If txtMname.Text <> "" Or txtMname.Text <> txtFname.Tag Then
            txtMname.Text = UCase(Mid(txtMname.Text, 1, 1)) & Mid(txtMname.Text, 2)
        End If
    End Sub

    Private Sub txtLname_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtLname.LostFocus
        txtLname.Text = IIf(Trim(txtLname.Text) = "", txtLname.Tag, Trim(txtLname.Text))
        If txtLname.Text <> "" Or txtLname.Text <> txtFname.Tag Then
            txtLname.Text = UCase(Mid(txtLname.Text, 1, 1)) & Mid(txtLname.Text, 2)
        End If
    End Sub
    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            Dim form As New frmMasterBrowse
            form.strSearch = "Vendor"
            'Rahul_ITS@20072612
            '<<START
            form.StartPosition = FormStartPosition.Manual
            form.Height = MDIPharmacy.MdiScaleHeight
            form.Width = MDIPharmacy.MdiScaleWidth
            Dim pt As New Point
            pt.Y = ((MDIPharmacy.MdiScaleHeight - form.Height) / 2) + MDIPharmacy.pnlHeading.Height + MDIPharmacy.MenuStrip.Height
            pt.X = (MDIPharmacy.MdiScaleWidth - form.Width) / 2
            form.Location = pt
            form.ShowInTaskbar = False
            '>>END
            form.ShowDialog()
            _intVendorID = form.strRecordNo
            Call ClearData()
            If _intVendorID <> 0 Then
                Call ViewData()
                btnSave.Text = "&Update"
                'Modified By:-Vinit(2008/03/27)
                'Enabled the Delete Button on the basis of Financial Year
                If ConfigurationManager.AppSettings("FormMode") = "R" Then
                    btnDelete.Enabled = False
                Else
                    btnDelete.Enabled = True
                End If
                'btFlag = 1
            End If
            setTag()
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnSearch_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Function ValidateData() As Boolean
        Try
            Dim dtVendor As New DataTable
            Dim count As Integer
            If Trim(txtVendorName.Text) = "" Then
                BCommon.ShowMsgError(10061)
                txtVendorName.Focus()
                Return False
            End If
            If btnSave.Text = "&Save" Then
                dtVendor = BVendor.GetVendorNm()
                For count = 0 To dtVendor.Rows.Count - 1
                    If Trim(txtVendorName.Text) = dtVendor.Rows(count).Item("VendorName") Then
                        BCommon.ShowMsgError(10421)
                        txtVendorName.Focus()
                        Return False
                    ElseIf Trim(txtFDA.Text) = dtVendor.Rows(count).Item("FDA_NUM") Then
                        BCommon.ShowMsgError(10423)
                        txtFDA.Focus()
                        Return False
                    ElseIf Trim(txtLST.Text) = dtVendor.Rows(count).Item("L_S_T_NUM") Then
                        BCommon.ShowMsgError(10424)
                        txtLST.Focus()
                        Return False
                    ElseIf Trim(txtCST.Text) = dtVendor.Rows(count).Item("C_S_T_NUM") Then
                        BCommon.ShowMsgError(10425)
                        txtCST.Focus()
                        Return False
                    End If
                Next
            End If
            If Trim(cmbVendorCat.Text) = "" Then
                BCommon.ShowMsgError(10062)
                cmbVendorCat.Focus()
                Return False
            End If
            If Trim(txtMname.Text) = "<Middle Name>" Then
                txtMname.Text = ""
            End If
            If Trim(txtFname.Text) = "" Or Trim(txtFname.Text) = "<First Name>" Then
                BCommon.ShowMsgError(10011)
                'BCommon.ShowMsgError(10061)
                txtFname.Focus()
                Return False
            End If
            If Trim(txtLname.Text) = "" Or Trim(txtLname.Text) = "<Last Name>" Then
                BCommon.ShowMsgError(10012)
                'BCommon.ShowMsgError(10062)
                txtLname.Focus()
                Return False
            End If
            If Trim(txtFDA.Text) = "" Then
                BCommon.ShowMsgError(10063)
                txtFDA.Focus()
                Return False
            End If
            If Trim(txtLST.Text) = "" Then
                BCommon.ShowMsgError(10064)
                txtLST.Focus()
                Return False
            End If
            If Trim(txtCST.Text) = "" Then
                BCommon.ShowMsgError(10065)
                txtCST.Focus()
                Return False
            End If
            If Trim(txtEmail.Text) <> "" Then
                If BCommon.ValidateEmailID(txtEmail.Text) = False Then
                    txtEmail.Focus()
                    Return False
                End If
                ValidateData = True
            End If
            If Trim(txtPhone1.Text) <> "" Or Trim(txtPhone2.Text) <> "" Then
                If Trim(txtPhone1.Text) = Trim(txtPhone2.Text) Then
                    BCommon.ShowMsgError(10002)
                    txtPhone2.Focus()
                    Return False
                End If
            End If
            If Trim(txtPhone1.Text) <> "" Or Trim(txtMobile1.Text) <> "" Then
                If Trim(txtPhone1.Text) = Trim(txtMobile1.Text) Then
                    BCommon.ShowMsgError(10361)
                    txtPhone1.Focus()
                    Return False
                End If
            End If
            If Trim(txtPhone1.Text) <> "" Or Trim(txtMobile2.Text) <> "" Then
                If Trim(txtPhone1.Text) = Trim(txtMobile2.Text) Then
                    BCommon.ShowMsgError(10362)
                    txtPhone1.Focus()
                    Return False
                End If
            End If
            If Trim(txtPhone2.Text) <> "" Or Trim(txtMobile1.Text) <> "" Then
                If Trim(txtPhone2.Text) = Trim(txtMobile1.Text) Then
                    BCommon.ShowMsgError(10363)
                    txtPhone2.Focus()
                    Return False
                End If
            End If
            If Trim(txtPhone2.Text) <> "" Or Trim(txtMobile2.Text) <> "" Then
                If Trim(txtPhone2.Text) = Trim(txtMobile2.Text) Then
                    BCommon.ShowMsgError(10364)
                    txtPhone2.Focus()
                    Return False
                End If
            End If
            If Trim(txtMobile1.Text) <> "" Or Trim(txtMobile2.Text) <> "" Then
                If Trim(txtMobile1.Text) = Trim(txtMobile2.Text) Then
                    BCommon.ShowMsgError(10000)
                    txtMobile1.Focus()
                    Return False
                End If
            End If

            If Trim(txtDeliveryPeriod.Text.ToString) <> "" Then
                If Trim(txtDeliveryPeriod.Text.ToString) > 30 Then
                    BCommon.ShowMsgError(1007)
                    txtDeliveryPeriod.Focus()
                    Return False
                End If
            End If
            If Trim(txtCreditTime.Text) <> "" Then
                If Trim(txtCreditTime.Text) > 90 Then
                    BCommon.ShowMsgError(1006)
                    txtCreditTime.Focus()
                    Return False
                End If
            End If
            '>>End
            Return True
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "ValidataData")
            Me.Cursor = Cursors.Default
        End Try
    End Function

    Private Sub txtVendorName_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtVendorName.KeyDown
        'MessageBox.Show(e.KeyCode)
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then cmbVendorCat.Focus()
        If e.Shift = True Then
            If e.KeyCode = Keys.OemQuotes Or e.KeyCode = Keys.OemPeriod Then
                e.SuppressKeyPress = True
            End If
            If BCommon.ValidateText(e.KeyCode, "ALF", False) = False Then
                e.SuppressKeyPress = True
            End If
        End If
    End Sub

    Private Sub cmbVendorCat_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbVendorCat.KeyDown
        'Rahul_ITS@2007113 : Add following line
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then
            If sender.selectedindex = -1 Then sender.text = "" Else txtAddr1.Focus()
        End If
    End Sub

    Private Sub txtAddr1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtAddr1.KeyDown
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then
            cmbCountry.Focus()
        Else
            If BCommon.ValidateText(e.KeyCode, "ALFTEXT", False) = False Then
                e.SuppressKeyPress = True
            End If
        End If
    End Sub

    Private Sub cmbcity_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbcity.KeyUp
        'Rahul_ITS@2007113 : Add following line
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then txtPinCode.Focus()
    End Sub

    Private Sub txtPinCode_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtPinCode.KeyDown
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then txtPhone1.Focus()
        If e.Shift Then e.SuppressKeyPress = True : Exit Sub
        If BCommon.ValidateText(e.KeyCode, "NUM", False) = False Then    'Divya 29/10/2007
            e.SuppressKeyPress = True
        End If
    End Sub

    Private Sub cmbState_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbState.KeyUp
        If e.KeyCode = Keys.Enter Then cmbcity.Focus()
    End Sub

    Private Sub cmbCountry_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbCountry.KeyUp
        If e.KeyCode = Keys.Enter Then cmbState.Focus()
    End Sub

    Private Sub txtPhone1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtPhone1.KeyDown
        Try
            'Rahul_ITS@20071113 << START
            If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
            If e.KeyCode = Keys.Enter Then txtPhone2.Focus()
            'If e.Shift Then e.SuppressKeyPress = True : Exit Sub
            'If BCommon.ValidateText(e.KeyCode, "NUM", False) = False Then    'Divya 29/10/2007
            '    e.SuppressKeyPress = True
            'End If

            If e.Shift = True Then
                If (e.KeyCode >= 48 And e.KeyCode <= 48 + 10) Or (e.KeyCode >= 96 And e.KeyCode <= 96 + 10) Then
                    e.SuppressKeyPress = True
                    Me.Cursor = Cursors.Default
                    Exit Sub
                End If
            End If
            If BCommon.ValidateMiscell(e.KeyCode, "QTY") = False Then e.SuppressKeyPress = True
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtphone1_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtPhone2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtPhone2.KeyDown
        Try
            'Rahul_ITS@20071113 << START
            If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
            If e.KeyCode = Keys.Enter Then txtMobile1.Focus()
            'If e.Shift Then e.SuppressKeyPress = True : Exit Sub
            'If BCommon.ValidateText(e.KeyCode, "NUM", False) = False Then    'Divya 29/10/2007
            '    e.SuppressKeyPress = True
            'End If
            If e.Shift = True Then
                If (e.KeyCode >= 48 And e.KeyCode <= 48 + 10) Or (e.KeyCode >= 96 And e.KeyCode <= 96 + 10) Then
                    e.SuppressKeyPress = True
                    Me.Cursor = Cursors.Default
                    Exit Sub
                End If
            End If
            If BCommon.ValidateMiscell(e.KeyCode, "QTY") = False Then e.SuppressKeyPress = True
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtphone1_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtMobile1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtMobile1.KeyDown
        Try
            'Rahul_ITS@20071113 << START
            If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
            If e.KeyCode = Keys.Enter Then txtMobile2.Focus()
            'If e.Shift Then e.SuppressKeyPress = True : Exit Sub
            'If BCommon.ValidateText(e.KeyCode, "NUM", False) = False Then    'Divya 29/10/2007
            '    e.SuppressKeyPress = True
            'End If

            If e.Shift = True Then
                If (e.KeyCode >= 48 And e.KeyCode <= 48 + 10) Or (e.KeyCode >= 96 And e.KeyCode <= 96 + 10) Then
                    e.SuppressKeyPress = True
                    Me.Cursor = Cursors.Default
                    Exit Sub
                End If
            End If
            If BCommon.ValidateMiscell(e.KeyCode, "QTY") = False Then e.SuppressKeyPress = True
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtphone1_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtFax_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtFax.KeyDown
        Try
            'Rahul_ITS@20071113 << START
            If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
            If e.KeyCode = Keys.Enter Then txtEmail.Focus()
            'If e.Shift Then e.SuppressKeyPress = True : Exit Sub
            'If BCommon.ValidateText(e.KeyCode, "NUM", False) = False Then    'Divya 29/10/2007
            '    e.SuppressKeyPress = True
            'End If

            If e.Shift = True Then
                If (e.KeyCode >= 48 And e.KeyCode <= 48 + 10) Or (e.KeyCode >= 96 And e.KeyCode <= 96 + 10) Then
                    e.SuppressKeyPress = True
                    Me.Cursor = Cursors.Default
                    Exit Sub
                End If
            End If
            If BCommon.ValidateMiscell(e.KeyCode, "QTY") = False Then e.SuppressKeyPress = True
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtfax_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtEmail_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtEmail.KeyDown
        Try
            'Rahul_ITS@20071113 << START
            If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
            '>> END
            If e.KeyCode = Keys.Enter Then txtRegisteredName.Focus()
            If BCommon.ValidateText(e.KeyCode, "ALFTEXT", False) = False Then    'Divya 29/10/2007
                e.SuppressKeyPress = True
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtEmail_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtMobile2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtMobile2.KeyDown
        Try
            'Rahul_ITS@20071113 << START
            If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
            If e.KeyCode = Keys.Enter Then txtFax.Focus()
            'If e.Shift Then e.SuppressKeyPress = True : Exit Sub
            'If BCommon.ValidateText(e.KeyCode, "NUM", False) = False Then    'Divya 29/10/2007
            '    e.SuppressKeyPress = True
            'End If

            If e.Shift = True Then
                If (e.KeyCode >= 48 And e.KeyCode <= 48 + 10) Or (e.KeyCode >= 96 And e.KeyCode <= 96 + 10) Then
                    e.SuppressKeyPress = True
                    Me.Cursor = Cursors.Default
                    Exit Sub
                End If
            End If
            If BCommon.ValidateMiscell(e.KeyCode, "QTY") = False Then e.SuppressKeyPress = True
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtfax_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtRegisteredName_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtRegisteredName.KeyDown
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then
            cmbTitle.Focus()
        Else
            If BCommon.ValidateText(e.KeyCode, "ALF", False) = False Then
                e.SuppressKeyPress = True
            End If
        End If
    End Sub

    Private Sub cmbTitle_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbTitle.KeyUp
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then
            If ConfigurationManager.AppSettings("NameSeq") = "TLFM" Then
                txtLname.Focus()
            Else
                txtFname.Focus()
            End If
        End If
    End Sub
    'Divya@13/02/2008 : Added for Tab key sequence for Name
    Private Sub cmbTitle_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbTitle.Leave
        If Keys.Tab Then
            If ConfigurationManager.AppSettings("NameSeq") = "TLFM" Then
                txtLname.Focus()
                txtLname.Tag = txtLname.Text
            Else
                txtFname.Focus()
                txtFname.Tag = txtFname.Text
            End If
        End If
    End Sub

    Private Sub txtFDA_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtFDA.KeyDown
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then txtLST.Focus()
        'If e.Shift Then e.SuppressKeyPress = True : Exit Sub
        'If BCommon.ValidateText(e.KeyCode, "ALFTEXT", False) = False Then    'Divya 29/10/2007
        '    e.SuppressKeyPress = True
        'End If
        'If e.KeyCode = 191 Then e.SuppressKeyPress = False

        If e.Shift = True Then
            If (e.KeyCode >= 48 And e.KeyCode <= 48 + 10) Or (e.KeyCode >= 96 And e.KeyCode <= 96 + 10) Then
                e.SuppressKeyPress = True
                Me.Cursor = Cursors.Default
                Exit Sub
            End If
        End If
        If BCommon.ValidateMiscell(e.KeyCode, "USERID") = False Then e.SuppressKeyPress = True
    End Sub

    Private Sub txtLST_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtLST.KeyDown
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then txtCST.Focus()
        'If e.Shift Then e.SuppressKeyPress = True : Exit Sub
        'If BCommon.ValidateText(e.KeyCode, "ALFTEXT", False) = False Then    'Divya 29/10/2007
        '    e.SuppressKeyPress = True
        'End If
        'If e.KeyCode = 191 Then e.SuppressKeyPress = False

        If e.Shift = True Then
            If (e.KeyCode >= 48 And e.KeyCode <= 48 + 10) Or (e.KeyCode >= 96 And e.KeyCode <= 96 + 10) Then
                e.SuppressKeyPress = True
                Me.Cursor = Cursors.Default
                Exit Sub
            End If
        End If
        If BCommon.ValidateMiscell(e.KeyCode, "USERID") = False Then e.SuppressKeyPress = True
    End Sub

    Private Sub txtCST_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtCST.KeyDown
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then txtPAN.Focus()
        'If e.Shift Then e.SuppressKeyPress = True : Exit Sub
        'If BCommon.ValidateText(e.KeyCode, "ALFTEXT", False) = False Then    'Divya 29/10/2007
        '    e.SuppressKeyPress = True
        'End If
        'If e.KeyCode = 191 Then e.SuppressKeyPress = False

        If e.Shift = True Then
            If (e.KeyCode >= 48 And e.KeyCode <= 48 + 10) Or (e.KeyCode >= 96 And e.KeyCode <= 96 + 10) Then
                e.SuppressKeyPress = True
                Me.Cursor = Cursors.Default
                Exit Sub
            End If
        End If
        If BCommon.ValidateMiscell(e.KeyCode, "USERID") = False Then e.SuppressKeyPress = True
    End Sub

    Private Sub txtPAN_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtPAN.KeyDown
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then cmbPayMode.Focus()
        'If e.Shift Then e.SuppressKeyPress = True : Exit Sub
        'If BCommon.ValidateText(e.KeyCode, "ALFTEXT", False) = False Then    'Divya 29/10/2007
        '    e.SuppressKeyPress = True
        'End If
        'If e.KeyCode = 191 Then e.SuppressKeyPress = False

        If e.Shift = True Then
            If (e.KeyCode >= 48 And e.KeyCode <= 48 + 10) Or (e.KeyCode >= 96 And e.KeyCode <= 96 + 10) Then
                e.SuppressKeyPress = True
                Me.Cursor = Cursors.Default
                Exit Sub
            End If
        End If
        If BCommon.ValidateMiscell(e.KeyCode, "USERID") = False Then e.SuppressKeyPress = True
    End Sub

    Private Sub cmbPayMode_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbPayMode.KeyDown
        'Rahul_ITS@2007113 : Add following line
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then txtDeliveryPeriod.Focus()
    End Sub

    Private Sub txtDeliveryPeriod_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtDeliveryPeriod.KeyDown
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then txtCreditTime.Focus()
        If e.Shift Then e.SuppressKeyPress = True : Exit Sub
        If BCommon.ValidateText(e.KeyCode, "NUM", False) = False Then    'Divya 29/10/2007
            e.SuppressKeyPress = True
        End If
    End Sub

    Private Sub txtCreditTime_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtCreditTime.KeyDown
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then txtNotes.Focus()
        If e.Shift Then e.SuppressKeyPress = True : Exit Sub
        If BCommon.ValidateText(e.KeyCode, "NUM", False) = False Then    'Divya 29/10/2007
            e.SuppressKeyPress = True
        End If
    End Sub

    Private Sub txtNotes_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtNotes.KeyDown
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then
            cmbmanufacturer.Focus()
        Else
            If BCommon.ValidateText(e.KeyCode, "ALFTEXT", False) = False Then
                e.SuppressKeyPress = True
            End If
        End If
    End Sub

    Private Sub txtvendorID_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtvendorID.KeyDown
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then
            txtVendorName.Focus()
        Else
            If BCommon.ValidateText(e.KeyCode, "ALFTEXT", False) = False Then
                e.SuppressKeyPress = True
            End If
        End If
    End Sub

    Private Sub cmbmanufacturer_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbmanufacturer.KeyDown
        'Rahul_ITS@2007113 : Add following line
        If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
        If e.KeyCode = Keys.Enter Then
            If sender.selectedindex = -1 Then sender.text = "" Else lstitemmfr.Focus()
        End If
    End Sub

    Private Sub cmbmanufacturer_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbmanufacturer.SelectedIndexChanged
        Dim intcount As Integer
        Dim dtDItem As New DataSet
        Dim stritem As String = ""
        Dim Items
        Try
            Me.Cursor = Cursors.WaitCursor
            If cmbmanufacturer.SelectedIndex > 0 Then
                lstitemvndr.DataSource = Nothing
                '  intcount = lstitemmfr.Items.IndexOf(HstItemList.Item(cmbmanufacturer.SelectedValue))
                Call selectVendorManufacturer(cmbmanufacturer.SelectedValue.ToString, lstitemmfr)
                'lstitemmfr.DataSource
                stritem = HstItemList.Item(cmbmanufacturer.SelectedValue)
                If Not IsNothing(stritem) Then
                    If InStr(stritem, ",") Then
                        Items = Split(stritem, ",")
                        Dim dtbSource As DataTable = lstitemmfr.DataSource
                        For intcount = 0 To UBound(Items)
                            Dim Values(1) As Object
                            Dim keyColumn(0) As DataColumn
                            keyColumn(0) = dtbSource.Columns("itemId")
                            dtbSource.PrimaryKey = keyColumn
                            Values(0) = Items(intcount)
                            dtDItem = DItem.GetItem(Items(intcount))
                            Values(1) = dtDItem.Tables(0).Rows(0).Item(3)
                            If Not IsNothing(dtbSource.Rows.Find(Values(0))) Then
                                dtbSource.Rows.Remove(dtbSource.Rows.Find(Values(0)))
                            End If

                            'dtbSource.Rows.Remove(dtbSource.Rows.Find(Values(0)))
                            If IsNothing(lstitemvndr.DataSource) Then
                                Dim dtbDest As New DataTable
                                dtbDest = DItem.GetmfctrItems("0")
                                lstitemvndr.DataSource = dtbDest
                                lstitemvndr.ValueMember = dtbDest.Columns(0).Caption
                                lstitemvndr.DisplayMember = dtbDest.Columns(1).Caption
                            End If
                            lstitemvndr.DataSource.Rows.Add(Values)
                        Next
                    Else
                        dtDItem = DItem.GetItem(Val(stritem))
                        Dim Values(1) As Object
                        dtDItem = DItem.GetItem(stritem)
                        'For intcount = 0 To lstitemmfr.Items.Remove   
                        Values(0) = dtDItem.Tables(0).Rows(0).Item(0)
                        Values(1) = dtDItem.Tables(0).Rows(0).Item(3)
                        'lstitemmfr.Items.Remove(Values)
                        Dim dtbSource As DataTable = lstitemmfr.DataSource
                        Dim keyColumn(0) As DataColumn
                        keyColumn(0) = dtbSource.Columns("itemId")
                        dtbSource.PrimaryKey = keyColumn
                        If Not IsNothing(dtbSource.Rows.Find(Values(0))) Then
                            dtbSource.Rows.Remove(dtbSource.Rows.Find(Values(0)))
                        End If

                        'dtbSource.Rows.Remove(dtbSource.Rows.Find(Values(0)))
                        'lstitemmfr.DataSource.Rows.Remove(dtDItem.Tables(0).Rows(0))
                        'dtDItem.Tables(0).Rows.r )
                        If IsNothing(lstitemvndr.DataSource) Then
                            Dim dtbDest As New DataTable
                            dtbDest = DItem.GetmfctrItems("0")
                            lstitemvndr.DataSource = dtbDest
                            lstitemvndr.ValueMember = dtbDest.Columns(0).Caption
                            lstitemvndr.DisplayMember = dtbDest.Columns(1).Caption
                        End If
                        lstitemvndr.DataSource.Rows.Add(Values)

                        'lstitemmfr.Items.Remove(    
                    End If
                End If
            Else
                lstitemmfr.DataSource = Nothing
                lstitemvndr.DataSource = Nothing
            End If
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "cmbmanufacturer_SelectedIndexChanged")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub selectVendorManufacturer(ByRef Name As String, ByRef lstitem As ListBox)
        Dim dtDItems As New DataTable
        Try
            dtDItems = DItem.GetmfctrItems(Name)
            lstitem.DataSource = dtDItems
            If dtDItems.Rows.Count > 0 Then
                lstitem.ValueMember = dtDItems.Columns(0).Caption
                lstitem.DisplayMember = dtDItems.Columns(1).Caption
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "selectVendorManufacturer")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub btnLAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLAll.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            If lstitemvndr.Items.Count > 0 Then TransferItem(lstitemvndr, lstitemmfr, "R", True)
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnROne_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub btnLOne_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLOne.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            If lstitemvndr.SelectedItems.Count > 0 Then Call TransferItem(lstitemvndr, lstitemmfr, "R")
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnLOne_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub btnRAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRAll.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            If lstitemmfr.Items.Count > 0 Then Call TransferItem(lstitemmfr, lstitemvndr, "A", True)
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnRAll_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub btnROne_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnROne.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            If lstitemmfr.SelectedItems.Count > 0 Then Call TransferItem(lstitemmfr, lstitemvndr, "A")
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnROne_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub TransferItem(ByRef lstSource As ListBox, ByRef lstDest As ListBox, ByVal AddRemove As Char, Optional ByVal TransAll As Boolean = False)
        Try
            Dim dtbSource As DataTable = lstSource.DataSource.Copy()
            Dim count As Integer, intCount As Integer, Count1 As Integer
            Dim StrItem As String = "", Items As String = ""
            Dim strID
            'StrItem = ""
            ' flgsave = 1
            If TransAll = True Then
                If lstDest.Items.Count > 0 Then
                    If AddRemove = "A" Then
                        StrItem = HstItemList.Item(cmbmanufacturer.SelectedValue)
                        HstItemList.Remove(cmbmanufacturer.SelectedValue)
                        For count = 0 To lstSource.Items.Count - 1
                            Dim Values(1) As Object
                            Values(0) = dtbSource.Rows(count).Item(0)
                            Values(1) = dtbSource.Rows(count).Item(1)
                            lstDest.DataSource.Rows.Add(Values)
                            StrItem = StrItem + "," + Trim(Values(0))
                        Next
                        HstItemList.Add(cmbmanufacturer.SelectedValue, StrItem)
                    Else
                        For count = 0 To lstSource.Items.Count - 1
                            Dim Values(1) As Object
                            Values(0) = dtbSource.Rows(count).Item(0)
                            Values(1) = dtbSource.Rows(count).Item(1)
                            lstDest.DataSource.Rows.Add(Values)
                        Next
                        HstItemList.Remove(cmbmanufacturer.SelectedValue)
                    End If
                Else
                    FillList(lstDest, dtbSource)
                    If AddRemove = "A" Then
                        For intCount = 0 To dtbSource.Rows.Count - 1
                            If intCount = 0 Then
                                StrItem = StrItem + Trim(dtbSource.Rows(intCount).Item(0))
                            Else
                                StrItem = StrItem + "," + Trim(dtbSource.Rows(intCount).Item(0))
                            End If
                        Next
                        HstItemList.Add(cmbmanufacturer.SelectedValue, StrItem)
                    Else
                        HstItemList.Remove(cmbmanufacturer.SelectedValue)
                    End If
                End If
                lstSource.DataSource.Clear()
            Else
                If IsNothing(lstDest.DataSource) Then
                    Dim dtbDest As New DataTable
                    dtbDest = DItem.GetmfctrItems("0")
                    lstDest.DataSource = dtbDest
                    lstDest.ValueMember = dtbDest.Columns(0).Caption
                    lstDest.DisplayMember = dtbDest.Columns(1).Caption
                End If

                If lstSource.Items.Count > 0 Then
                    Dim Values(1) As Object
                    Dim selitems(lstSource.SelectedItems.Count - 1) As Integer
                    For count = 0 To lstSource.SelectedItems.Count - 1
                        Values(0) = dtbSource.Rows(lstSource.SelectedIndices.Item(count)).Item(0)
                        Values(1) = dtbSource.Rows(lstSource.SelectedIndices.Item(count)).Item(1)
                        lstDest.DataSource.Rows.Add(Values)
                        If AddRemove = "A" Then
                            If lstDest.DataSource.Rows.Count > 1 Then
                                StrItem = HstItemList.Item(cmbmanufacturer.SelectedValue) + "," + Trim(Values(0))
                                HstItemList.Item(cmbmanufacturer.SelectedValue) = StrItem
                            Else
                                StrItem = StrItem + Trim(Values(0))
                                HstItemList.Add(cmbmanufacturer.SelectedValue, StrItem)
                            End If
                        Else
                            StrItem = HstItemList.Item(cmbmanufacturer.SelectedValue)
                            If InStr(StrItem, ",") Then
                                strID = Split(StrItem, ",")

                                For Count1 = 0 To UBound(strID)
                                    'write fun for replacing string
                                    If Trim(Values(0)) = strID(Count1) Then
                                        Items = RemoveItem(StrItem, Trim(Values(0))) 'StrItem.Replace(Trim(Values(0)) + ",", "")
                                        HstItemList.Item(cmbmanufacturer.SelectedValue) = Items
                                    End If
                                Next
                            Else
                                If Trim(Values(0)) = StrItem Then
                                    HstItemList.Remove(cmbmanufacturer.SelectedValue)
                                End If
                            End If
                        End If
                        selitems(count) = lstSource.SelectedIndices.Item(count)
                    Next

                    For count = selitems.Length - 1 To 0 Step -1
                        lstSource.DataSource.Rows.RemoveAt(selitems(count))
                    Next
                End If
            End If
            Flag = 1
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "TransferItem")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Function RemoveItem(ByVal Items As String, ByVal strReplace As String) As String
        Dim Pos As Integer
        Dim length As Integer
        Try
            Pos = Items.IndexOf(strReplace)
            length = Len(strReplace)
            If Pos = 0 Then
                If Items.Substring(Pos + length, 1) = "," Then
                    Items = Items.Remove(Pos, length + 1)
                    ' Return Items
                End If
            Else
                If Pos + length = Len(Items) Then  'No. present at last
                    Items = Items.Remove(Pos - 1, length + 1)
                Else
                    If Items.Substring(Pos + length, 1) = "," And Items.Substring(Pos - 1, 1) = "," Then 'Comma after & Bwefore no.
                        Items = Items.Remove(Pos - 1, length + 1)
                        'Return Items
                    End If
                End If
            End If
            Return Items
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "RemoveItem")
            Me.Cursor = Cursors.Default
            Return Nothing
        End Try
    End Function

    Private Sub FillList(ByRef lstBox As ListBox, ByVal dtbTable As DataTable)
        Try
            lstBox.DataSource = dtbTable
            lstBox.ValueMember = dtbTable.Columns(0).Caption
            lstBox.DisplayMember = dtbTable.Columns(1).Caption
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "FillList")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbmanufacturer_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles cmbmanufacturer.Validating
        If sender.selectedindex = -1 Then sender.text = ""
    End Sub

    Private Sub cmbVendorCat_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles cmbVendorCat.Validating
        If sender.selectedindex = -1 Then sender.text = ""
    End Sub

    'Rahul_ITS@20072712 : Add following code
    '<<START
    Private Sub lstitemmfr_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles lstitemmfr.KeyDown
        Try
            If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
            If e.KeyCode = Keys.Enter Or (e.KeyCode = Keys.ControlKey And e.KeyCode = Keys.S) Then
                If lstitemmfr.SelectedItems.Count > 0 Then Call TransferItem(lstitemmfr, lstitemvndr, "A")
            ElseIf (e.Control = True And e.KeyCode = Keys.A) Then
                If lstitemmfr.Items.Count > 0 Then Call TransferItem(lstitemmfr, lstitemvndr, "A", True)
            ElseIf (e.Control = True And e.KeyCode = Keys.S) Then
                If lstitemmfr.SelectedItems.Count > 0 Then Call TransferItem(lstitemmfr, lstitemvndr, "A")
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "lstitemmfr_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub lstitemvndr_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles lstitemvndr.KeyDown
        Try
            If e.Alt Then Me.Cursor = Cursors.Default : Exit Sub
            If e.KeyCode = Keys.Enter Then
                If lstitemvndr.SelectedItems.Count > 0 Then Call TransferItem(lstitemvndr, lstitemmfr, "R")
            ElseIf (e.Control = True And e.KeyCode = Keys.A) Then
                If lstitemvndr.Items.Count > 0 Then TransferItem(lstitemvndr, lstitemmfr, "R", True)
            ElseIf (e.Control = True And e.KeyCode = Keys.S) Then
                If lstitemvndr.SelectedItems.Count > 0 Then Call TransferItem(lstitemvndr, lstitemmfr, "R")
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "lstitemvndr_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub lstitemmfr_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lstitemmfr.MouseDoubleClick
        Try
            Me.Cursor = Cursors.WaitCursor
            If lstitemmfr.SelectedItems.Count > 0 Then Call TransferItem(lstitemmfr, lstitemvndr, "A")
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "lstitemmfr_MouseDoubleClick")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub lstitemvndr_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lstitemvndr.MouseDoubleClick
        Try
            Me.Cursor = Cursors.WaitCursor
            If lstitemvndr.SelectedItems.Count > 0 Then Call TransferItem(lstitemvndr, lstitemmfr, "R")
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "Lblitemmfr_MouseDoubleClick")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub btnLAll_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles btnLAll.KeyDown
        Try
            If e.KeyCode = Keys.A Then
                txtVendorName.Focus()
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnLAll_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            If (BVendor.IsVendorUsed(_intVendorID)) = 0 Then
                If (BVendor.DeleteVendor(_intVendorID)) > 0 Then
                    BCommon.ShowMsgError(10353)
                    txtVendorName.Focus()
                    Call ClearData()
                    Call Display_Data()
                    Call setTag()
                    blnCountryFlag = True
                    blnStateFlag = True
                    blnCityFlag = True
                    cmbTitle.Tag = cmbTitle.SelectedValue
                    btnSave.Text = "&Save"
                    btnDelete.Enabled = False
                End If
            Else
                BCommon.ShowMsgError(10352)
                btnDelete.Focus()
            End If
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnDelete_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub
End Class